import { fakeRegister } from './service';

const Model = {
  namespace: 'userAndUserRegister',
  state: {
    status: undefined,
  },
  effects: {
    *submit({ payload}, { call, put }) {
      const response = yield call(fakeRegister, payload);
/*      
  if (response.code === 200) {
    if (callback && typeof callback === 'function') {
      callback(response); // 返回结果
    }
  } else {
    notification.error({
      message: response.msg,
    });
  }*/
    const { code, status } = response;
    console.log("the code is",response.status);
    if(status === "ok") {
        //接口调用成功
        // do something...
        return status;    //  通过return给dispatch返回回调结果！
    }else {
        //接口调用失败
        // do something...
        return status;
    }



      yield put({
        type: 'registerHandle',
        payload: response,
      });
    },
  },
  reducers: {
    registerHandle(state, { payload }) {
      return { ...state, status: payload.status };
    },
  },
};
export default Model;
